/**********************************
 ***	Imports
 **********************************/
package fr.montreuil.wargame.controller;

import javax.validation.Valid;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import fr.montreuil.wargame.domain.UserForm;

/**********************************
 *** 	@jgay
 *** 	@9 mai 2012
 **********************************/
@Controller
@RequestMapping("/validator")
public class TestValidatorController {
	@RequestMapping(method = RequestMethod.GET)
    public String get(final ModelMap model) {
 
        UserForm userForm = new UserForm();
        model.addAttribute("userForm", userForm);
        return "form";
    }
 
    @RequestMapping(method = RequestMethod.POST)
    public String post(final ModelMap model, @Valid final UserForm userForm,
        final BindingResult result) {
 
        if (result.hasErrors()) {
            return "form";
        }
 
        return "success";
    }

}
